
public class Text {
    static int count = 0;
    private static final Object locker1 = new Object();
    private static final Object locker2 = new Object();
    private static final Object locker3 = new Object();
    public static void main(String[] args) throws InterruptedException {

        Thread a = new Thread(()->{
            synchronized (locker1) {
                try {
                    locker1.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.print("a");

        });
        Thread b = new Thread(()->{
            synchronized (locker2) {
                try {
                    locker2.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.print("b ");
            synchronized (locker1) {
                locker1.notify();
            }
        });
        Thread c = new Thread(()->{
            synchronized (locker3) {
                try {
                    locker3.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.print("c ");
            synchronized (locker2) {
                locker2.notify();
            }
        });
        a.start();
        b.start();
        c.start();

        Thread.sleep(1000);
        synchronized (locker3){
            locker3.notify();
        }

    }

}
